using System;
using System.DirectoryServices;
using RollManager.Library.ActionSteps.BaseClasses;

namespace RollManager.Library.ActionSteps
{
    [Serializable]
    public class IISSiteGetStep : IISStep
    {
        public override string Name
        {
            get { return "IIS Get Site Property"; }
        }

        protected override void Run()
        {
            DirectoryEntry entry = getEntry();

            // Get property
            if( string.IsNullOrEmpty( WebSite ) )
            {
                Progress.AddFormat( "{0} is set to: {1}", PropertyPath, displayProperty( entry.InvokeGet( PropertyName ) ) );
            }
            else
            {
                Progress.AddFormat( "{0} is set to: {1} on {2}.", PropertyPath, displayProperty( entry.InvokeGet( PropertyName ) ), WebSite );
            }
        }

        protected override void Simulate()
        {
            Run();
        }
    }
}
